package collection;

import javax.management.Query;
import java.util.*;

/**
 * @author xiaoming
 * @version 1.0
 * @date 2019-03-20 18:36
 **/
public class MapDemo {
    public static void main(String[] args) {
        ArrayList list = new ArrayList();
        // ArrayList 不能容纳基本类型, 自动装箱
        list.add(12);
        int x = (int) list.get(0);
        System.out.println(x);

        // Queue pool()和 remove() 区别
        PriorityQueue priorityQueue = new PriorityQueue();
        priorityQueue.poll(); // 空
        //priorityQueue.remove(); // 抛出异常

        // 确保集合不能被修改
        List<String> list1 = new ArrayList<>();
        list1.add("x");
        Collection<String> clist = Collections.unmodifiableCollection(list1);
        try {
            clist.add("y"); // java.lang.UnsupportedOperationException;
        } finally {
            System.out.println(clist.size()); // 1
        }

    }
}
